package com.cdwm.mrp.controller;


import com.cdwm.mrp.domain.po.User;
import com.cdwm.mrp.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @version v1.0
 * @Author: lyw
 * @Date: 2021/8/3
 */
@Controller
@Slf4j
@RequestMapping("/person")
public class PersonController {

    @Autowired
    private UserService userServices;

    @GetMapping("/person")
    public String person(){
        return "view/system/user/person";
    }



    @GetMapping("/uploadProfile")
    public String uploadProfile(){
        return "view/system/user/uploadProfile";
    }

    @PostMapping("/uploadUserAvatar")
    @ResponseBody
    public String uploadUserAvatar(HttpSession session, String bold){
        User user = (User) session.getAttribute("user");
        user.setAvatar(bold);
        userServices.updateById(user);
        return bold;
    }
}
